package com.cn.dao.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.cn.dao.OrderDetailDao;
import com.cn.domain.Order;
import com.cn.domain.OrderDetail;
import com.cn.utils.DBUtils;

public class OrderDetailDaoImpl implements OrderDetailDao{
	//查询订单详细表中的商品数量
	public OrderDetail queryOrderDetByOrderId(long id) {
		OrderDetail od=null;
		try {
			Object[] params={id};
			od=DBUtils.getQuryRunner().query("select * from HWUA_ORDER_DETAIL where HO_ID=?",new BeanHandler<OrderDetail>(OrderDetail.class),params);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return od;
	}

	//获取所有的订单详情记录
	@Override
	public List<OrderDetail> queryAllOrderDetail() {
		List<OrderDetail> list=new ArrayList();
		try {
			String sql="select * from HWUA_ORDER_DETAIL";
			list=DBUtils.getQuryRunner().query(sql,new BeanListHandler<OrderDetail>(OrderDetail.class));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}
}
